import PasswordInput from '../../../components/NewPassword'
import { connect } from 'dva'
const NewPassword = ({ dispatch, loadPage, content, modalControl,  }) => {
  const next = () => {
    dispatch({
      type: 'modules/getModules',
      payload: {
        title: '资金密码修改',
        process: 'modifyFundPassword',
        businessId: '1231241207',
        pathname: '',
        tokenId: 'test'
      }
    })
    dispatch({
      type: 'modifyFundPassword/changePage',
      payload: {
        loadPage: (loadPage += 1),
        content:'',
        modalControl:false,
      }
    })
  }
  let listData
  switch (loadPage) {
    case 1:
      listData = [
        {
          key: 'passowrd',
          value: '原资金密码',
          className: 'haveNoBorder',
          errorContent: '请输入6位资金密码',
          reg:/^(\d{6})$/
        }
      ]
      break
    case 2:
      listData = [
        {
          key: 'passowrd',
          value: '资金密码',
          className: 'haveNoBorder',
          errorContent: '请输入6位资金密码',
          reg:/^(\d{6})$/,
          children: {
            reg:/^(\d{6})$/,
            key: 'passwordConfirm',
            className: 'haveNoBorder',
            errorContent: '您输入的交易密码不一致,请重新输入'
          }
        }
      ]
      break
    case 3:
      listData = [
        {
          key: 'passowrd',
          value: '交易金密码',
          className: 'haveNoBorder'
        }
      ]
      break
    case 4:
      listData = [
        {
          key: 'passowrd',
          value: '原资金密码',
          className: 'haveNoBorder',
          errorContent: '请输入6位资金密码',
          reg:/^(\d{6})$/
        }
      ]
      break
    default:
      listData = []
    break
  }

  const passwordData = {
    listData,
    next,
    content,
    modalControl,
    closeModal: () => {
      dispatch({
        type: 'modifyFundPassword/changePage',
        payload: {
          loadPage: loadPage,
          modalControl: false
        }
      })
    },
    showModal: (content) => {
      dispatch({
        type: 'modifyFundPassword/changePage',
        payload: {
          modalControl: true,
          loadPage: loadPage,
          content
        }
      })
    }
  }
  return <PasswordInput {...passwordData} />
}
export default connect(state => state.modifyFundPassword)(NewPassword)
